﻿using System;
using System.Collections.Generic;
using System.Text;

namespace IceDog.EFCore.Utils
{
    public class ConnectionStringHelper
    {
        private static Dictionary<string, string> cache = new Dictionary<string, string>(3);

        public static string MySql
        {
            get
            {
                if (cache.ContainsKey("mysql"))
                {
                    return cache["mysql"];
                }
                var builder = new StringBuilder();
                builder.Append("Database=DioBlog;");//数据库名
                builder.Append("Data Source=localhost;");//数据源
                builder.Append("User Id=root;");
                builder.Append("Password=123456;");
                builder.Append("Port=3306;");
                builder.Append("Protocol=sockets;");
                builder.Append("Pooling=true;");
                builder.Append("Max Pool Size=32767;");
                builder.Append("Min Pool Size=10;");
                builder.Append("CharSet=utf8;");
                cache["mysql"] = builder.ToString();
                return cache["mysql"];
            }
        }
        public static string Oracle
        {
            get
            {
                if (cache.ContainsKey("oracle"))
                {
                    return cache["oracle"];
                }
                var builder = new StringBuilder();
                builder.Append("Data Source=oracle:1521/XE;");//数据源
                builder.Append("Persist Security Info=False;");
                builder.Append("User ID=System;");
                builder.Append("Password=1qaz2WSX;");
                builder.Append("Pooling=true;");
                builder.Append("Max Pool Size=200;");
                builder.Append("Min Pool Size=10;");
                cache["oracle"] = builder.ToString();
                return cache["oracle"];
            }
        }
        public static string SQLite
        {
            get
            {
                if (cache.ContainsKey("sqlite"))
                {
                    return cache["sqlite"];
                }
                var builder = new StringBuilder();
                //默认读取的数据库是在debug目录下的，这里是替换为在项目文件夹下的数据库
                builder.Append("Data Source=../../../DioBlog.db;");//数据源
                cache["sqlite"] = builder.ToString();
                return cache["sqlite"];
            }
        }
    }
}
